package cn.wp.common.core;

import cn.wp.common.core.authentication.AuthenticationProperties;
import cn.wp.common.core.plugin.fileserver.FileService;
import cn.wp.common.core.plugin.fileserver.FileServerProperties;
import cn.wp.common.core.util.ApplicationContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

/**
 * 框架主类
 * Created by chenyb on 2019/09/23
 */
public class Wp {

    // 框架core包
    public static final String CorePackage = "cn.wp.common.core";

    // 框架全局包
    public static final String GlobalPackage = "cn.wp";

    // 框架名
    public static final String NAME = "wp";

    // 版本号
    public static final String VERSION = "1.0.0";

    // 框架内部上下文路径
    public static final String WebContext = "/" + NAME;

    // 框架基础服务上下文路径
    public static final String WebCommonBase = WebContext + "/common";

    // 实例
    private static Wp INSTANCE;

    @Autowired
    private WpProperties wpProperties;

    @Autowired
    private WpPropertiesObject wpPropertiesObject;

    @Autowired
    private AuthenticationProperties authenticationProperties;

    @Autowired
    private FileServerProperties fileServerProperties;

    @Autowired
    private FileService fileServer;

    void instance(Wp wp){
        INSTANCE = wp;
    }

    public static Wp self(){
        return INSTANCE;
    }

    public WpPropertiesObject getWpPropertiesObject(){
        return wpPropertiesObject;
    }

    public WpProperties getWpProperties(){
        return wpProperties;
    }

    public AuthenticationProperties getAuthenticationProperties(){
        return authenticationProperties;
    }

    public FileServerProperties getFileServerProperties() {
        return fileServerProperties;
    }

    public FileService getFileServer() {
        return fileServer;
    }

    public ApplicationContext getApplicationContext(){
        return ApplicationContextUtil.getContext();
    }
}
